<?php

namespace app\admin\controller;

class Index extends base
{

    public function _initialize()
    {
        //覆盖原来的自动载入
    }

    public function index()
    {
        return $this->fetch();
    }

    public function welcome()
    {
        $this->assign('systemConfig', $this->systemConfig());
        return $this->fetch();
    }

    /**
     * @return array 服务器信息
     */
    private function systemConfig()
    {
        return $config = [
            '操作系统' => PHP_OS,
            '服务器时间' => date("Y-n-j H:i:s"),
            '运行环境' => $_SERVER["SERVER_SOFTWARE"],
            'PHP运行方式' => php_sapi_name(),
            '上传附件限制' => ini_get('upload_max_filesize'),
            '执行时间限制' => ini_get('max_execution_time') . '秒',
            '服务器IP地址' => $this->request->ip(),
            '服务器域名' => $this->request->domain(),
            '服务器端口 ' => $_SERVER['SERVER_PORT'],
            '运行环境 ' => $_SERVER['SERVER_SOFTWARE'],
            '本文件所在文件夹' => $_SERVER['SCRIPT_FILENAME'],
            '系统所在文件夹' => $_SERVER['DOCUMENT_ROOT'],
            'PHP运行方式：' => php_sapi_name(),
            '磁盘剩余空间 '=> round((@disk_free_space(".")/(1024*1024)),2).'M',
        ];

    }


    /**
     * @return 清理缓存
     */
    public function cleanCache()
    {
        deldir(RUNTIME_PATH);
//        return ajax_info('清理缓存！','y');
        return $this->success('清理缓存');
    }
}
